<?
require_once("mvc/action/Action.php");
require_once("cms/forum/om/TopicPeer.php");

class EditAction extends Action {

    private $log;

    public function __construct() {
        $this->log =& LoggerManager::getLogger("EditAction");
    }

    public function execute(ActionConfig &$mapping, &$form, Request &$request, Response &$response) {

        if($form->getTopic()->getTopicId() > 0) {
            $topic = TopicPeer::retrieveByPk($form->getTopic()->getTopicId());
            if(!is_null($topic)) {

                $form->setTopic($topic);

            } else {
                $this->log->error("No topic found with id {$form->getTopic()->getTopicId()}.");
                $form->getTopic()->setTopicId("");
            }

        }

        return $mapping->findForward("success");

    }

}
?>